home *** CD-ROM | disk | FTP | other *** search
- ;
- ; int creato(char *file, int mode, int attr)
- ; +8 +12 +16
- public creato
- creato proc near
- push ebp
- mov ebp,esp
- push ebx
- push edx
-
- reopen: mov ah,3Dh ; open file
- mov al,[ebp+12]
- mov edx,[ebp+8]
- int 21h
- jnc short cre_ok
-
- cmp ax,02h ; file not found
- jne short cre_er
-
- mov ah,3Ch ; creat file
- mov cx,[ebp+16]
- int 21h
- jc short cre_er
-
- mov bx,ax
- mov ah,3Eh ; close file
- int 21h
- jnc short reopen
-
- cre_er: mov errno,ax
- mov eax,-1
- jmp short cre_rt
-
- cre_ok: and eax,0FFFFh
- cre_rt: pop edx
- pop ebx
- pop ebp
- ret
- creato endp
-
- ;
- ; int close(int fp)
- ; +8
- public close
- close proc near
- push ebp
- mov ebp,esp
- push ebx
-
- mov ah,3Eh ; close
- mov bx,[ebp+8]
- int 21h
-
- jnc short cl_rt
- mov eax,-1
- jmp short cl_er
-
- cl_rt: mov eax,0
- cl_er: pop ebx
- pop ebp
- ret
- close endp
-
- ;
- ; int lseek(int fp,long pos,int sk)
- ; +8 +12 +16
- public lseek
- lseek proc near
- push ebp
- mov ebp,esp
- push ebx
-
- mov ah,42h ; seek
- mov al,[ebp+16]
- mov bx,[ebp+8]
- mov cx,[ebp+14]
- mov dx,[ebp+12]
- int 21h
-
- jnc short ls_rt
- mov eax,-1
- jmp short ls_er
-
- ls_rt: shl edx,16
- or eax,edx
- ls_er: pop ebx
- pop ebp
- ret
- lseek endp
-
- ;
- ; int read(int fp,void *buf,int sz)
- ; +8 +12 +16
- public read
- read proc near
- push ebp
- mov ebp,esp
- push ebx
-
- mov ah,3Fh ; read
- mov bx,[ebp+8]
- mov edx,[ebp+12]
- mov cx,[ebp+16]
- int 21h
-
- jnc short rd_rt
- mov eax,-1
- rd_rt: pop ebx
- pop ebp
- ret
- read endp
-
- ;
- ; int write(int fp,void *buf,int sz)
- ; +8 +12 +16
- public write
- write proc near
- push ebp
- mov ebp,esp
- push ebx
-
- mov ah,40h ; write
- mov bx,[ebp+8]
- mov edx,[ebp+12]
- mov cx,[ebp+16]
- int 21h
-
- jnc short wt_rt
- mov eax,-1
- wt_rt: pop ebx
- pop ebp
- ret
- write endp